package cn.yunbamboos.db;

import cn.hutool.core.io.FileUtil;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class ReadInitDataSQL {

    private final String sqlPath;

    public ReadInitDataSQL(String sqlPath) {
        this.sqlPath = sqlPath;
    }

    public List<String> read(){
        List<String> sqlList = new ArrayList<>();
        if(!FileUtil.exist(this.sqlPath)){
            return sqlList;
        }
        if(FileUtil.isDirEmpty(new File(this.sqlPath))){
            return sqlList;
        }
        File[] files = FileUtil.ls(this.sqlPath);
        for(File file : files){
            sqlList.addAll(FileUtil.readUtf8Lines(file));
        }
        return sqlList;
    }

}
